<template>
  <div class="dialog dialog5">
    <div ref="dialog5" class="dialogs" @click.native="moveNext">
      <template v-for="(item, index) in dialogs.dialog5">
        <div v-if="dialogCurrent === index && item.type === 'dialog'" :key="index" :class="item.class + ' dialog' + (index + 1)">
          <span>{{item.content}}</span>
        </div>
        <div v-else-if="dialogCurrent === index && item.type === 'action'" :key="index" :class="item.class + ' dialog' + (index + 1)">
          <div class="animated infinite zoomIn">
            <img src="../assets/yushan.png" alt="">
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
import dialogs from '../dialogs'

export default {
  name: 'HelloWorld',
  props: ['dialogCurrent'],
  data () {
    return {
      dialogs,
    }
  },
  watch: {
    dialogCurrent (val) {
      if (val > dialogs.dialog5.length - 2) {
        this.$emit('move-next')
      }
    }
  },
  methods: {
    moveNext(e) {
      e.preventDefault()
      console.log('moveNext')
      this.$emit('move-next')
      // this.currentDialogs++
    }
  }
}
</script>

<style lang="less" scoped>
.dialog5 {
  .dialog1 {
    top: .77rem;
    left: 1.79rem;
    width: 1.7rem;
  }
  .dialog2 {
    width: 1.7rem;
    top: 0.88rem;
    left: .1rem;
  }
  .dialog3 {
    background: transparent;
    left: 50%;
    top: 50%;
    width: .1rem;
    height: .1rem;
    width: 3rem;
    height: 3rem;
    animation-duration: 2.5s;
    transform: translate(-50%, -50%);
  }
}
</style>

